package javaBase2;

import java.io.Serializable;

public class Card implements Serializable {
	//牌面值
	private String showValue;
	
	//计算值
	/**
	 * 2到10 J Q K A 大王 小王
	 * 实际是 2到10 11 12 13 14 15 16
	 */
	private int realvalue;
	
	private CardStyle style = CardStyle.HEI_TAO;

	public String getShowValue() {
		return showValue;
	}

	private void setShowValue(String showValue) {
		this.showValue = showValue;
	}

	public int getRealvalue() {
		return realvalue;
	}
	public Card(){
		
	}
	public Card(int realvalue, CardStyle style) {
		setRealvalue(realvalue);
		setStyle(style);
	}

	public void setRealvalue(int realvalue) {
		this.realvalue = realvalue;
		if(realvalue <2 || realvalue>16){
			System.out.println("程序出错");
			System.exit(0);
		}
		//根据realvalue决定showValue的值
		switch(realvalue){
			case 11: {setShowValue("J");
			break;
			}
			case 12: {setShowValue("Q");
			break;
			}
			case 13: {setShowValue("K");
			break;
			}
			case 14: {setShowValue("A");
			break;
			}
			case 15: {setShowValue("小王");
			break;
			}
			case 16: {setShowValue("大王");
			break;
			}
			default:
				setShowValue(realvalue+"");
		}
		
	}

	@Override
	public String toString() {
		if(realvalue == 15 || realvalue == 16){
			return this.showValue;
		}
		else{
			return this.style +"" + this.showValue;
		}
	}

	public CardStyle getStyle() {
		return style;
	}

	public void setStyle(CardStyle style) {
		this.style = style;
	}

	public void setShowValue() {
		// TODO Auto-generated method stub
		
	}

	public void setStyle() {
		// TODO Auto-generated method stub
		
	}

}
